<%--
  Created by IntelliJ IDEA.
  User: blake
  Date: 2016/8/3
  Time: 20:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath }/css/common01.css"/>
    <title>广告管理</title>
    <script type="text/javascript">
        function deleteItems() {
            document.itemsForm.action="${pageContext.request.contextPath }/Customer/deleteAdvertisements.action";
            document.itemsForm.submit();
        }
        function insertItems() {
            document.itemsForm.action="${pageContext.request.contextPath }/Customer/addAdvertisement.action";
            document.itemsForm.submit();
        }
        function updateItems(id) {
            document.itemsForm.action="${pageContext.request.contextPath }/Customer/updateAdvertisementById.action?itemId="+id;
            document.itemsForm.submit();
        }

    </script>
</head>
<body>

<div class="container clearfix">
    <rapid:override name="main_wrap">
        <form name="itemsForm"
              action="${pageContext.request.contextPath }/Customer/findAdvertisementByName.action" method="post" id="itemsForm">
            <table width="100%" border="1" style="width: 79.9%;float: right;">
                <tr>
                    <td>广告名:<input type="text" name="advertisementName"
                                    value=""/></td>
                    <td>
                        <input type="submit" value="查询"/>
                        <input type="button" value="批量删除"
                               onclick="deleteItems()"/>
                        <input type="button" value="新增广告"
                               onclick="insertItems()"/>
                    </td>
                </tr>
            </table>
            <table class="main_wrap_table" id="customers">
                <tr>
                    <td>选择</td>
                    <td>广告id</td>
                    <td>广告名</td>
                    <td>图片URL</td>
                    <td>广告链接</td>
                    <td>广告状态</td>
                    <td>操作</td>
                </tr>
                <c:forEach items="${list}" var="lists">
                    <tr>
                        <td><input type="checkbox" name="advertiseId"
                                   value="${lists.id}">
                            <input type="text" name="strid" value="${lists.id}" style="display: none;"></td>
                        <td>${lists.id}</td>
                        <td><input type="text" value="${lists.name}"
                                   name="name" class="input"/></td>
                        <td><input type="text" value="${lists.url}"
                                   name="url" class="input"/></td>
                        <td><input type="text" value="${lists.link}"
                                   name="link" class="input"/></td>
                        <td id="status" class="status_c">
                            <c:choose>
                                <c:when test="${lists.status == 0}">
                                    展示中
                                </c:when>
                                <c:otherwise>
                                    不展示
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td>
                            <a href="${pageContext.request.contextPath }/Customer/deleteAdvertisementById.action?id=${lists.id}&page=${currentPage}">删除</a> |
                            <a href="${pageContext.request.contextPath }/Customer/changeAdvertisementStatus.action?page=${currentPage}&status=${lists.status}&id=${lists.id}" class="status_class" id="status_click"><c:choose><c:when test="${lists.status == 0}">隐藏广告</c:when><c:otherwise>展示广告</c:otherwise></c:choose></a> |
                            <input type="button" value="更新广告"
                                   onclick="updateItems(${lists.id})">
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </form>
        <div id="page">
            <ul>
                <li class="first">
                    <a href="${pageContext.request.contextPath }/Customer/returnAllAdvertisement.action?page=1">&nbsp;首页&nbsp;</a></li>
                <li class="upPage"><a
                        href="${pageContext.request.contextPath}/Customer/returnAllAdvertisement.action?page=<c:choose>
                        <c:when test="${currentPage == 1}">
                        ${1}
                        </c:when>
                        <c:otherwise>
                        ${currentPage-1}
                        </c:otherwise>
                        </c:choose>
                            ">&nbsp;上一页&nbsp;</a></li>
                <li class="nextPage"><a
                        href="${pageContext.request.contextPath}/Customer/returnAllAdvertisement.action?page=<c:choose>
                <c:when test="${list.size() < 8}">
                ${currentPage}
                </c:when>
                <c:otherwise>
                ${currentPage+1}
                </c:otherwise>
                </c:choose>
                ">&nbsp;下一页&nbsp;</a></li>
                <li class="lastPage"><a href="#">&nbsp;末页&nbsp;</a></li>
            </ul>
        </div>
    </rapid:override>
</div>

</body>
</html>
<%@include file="../common/templateJSP.jsp"%>